<template>
  <div>
    <h1>组件2的数字是: {{ getNum }}</h1>
    <h1>user空间: {{ nickname }}</h1>
    <button @click="changeName()">点击变名字</button>
  </div>
</template>

<script>
import { mapGetters, mapState, mapMutations } from 'vuex'
export default {
  computed: {
    ...mapState({
      nickname: state => state.user.nickname
    }),
    ...mapGetters(['getNum'])
  },
  methods: {
    ...mapMutations({
      changeName: 'user/changeName'
    })
  }
}
</script>
